<!-- The documentation for the automaton input step view. -->

<HTML><HEAD>
<TITLE>NFA to DFA</TITLE>
</HEAD><BODY>

<H1>NFA to DFA</H1>

<CENTER><IMG SRC="images/nfa2dfa.png" ALT="Conversion of NFA to DFA" WIDTH="581" HEIGHT="340" BORDER="1"></CENTER>

<P>This operator may be applied to any nondeterministic FA.  At the end of the operation, there will be a completed NFA.</P>

<P>The conversion practice used is the standard canonical method of creating an equivalent DFA from an NFA, that is: each state in the DFA being built corresponds to a nonempty set of states in the original NFA.  Therefore, for an NFA with <VAR>n</VAR> states, there are potentially <VAR>2<SUP>n</SUP> - 1</VAR> states in the DFA, though realistically this upper bound is rarely met.</P>

<P>The interface for the creating a DFA from an NFA is shown above.  The NFA is displayed for reference purposes in the left portion of the view.  The DFA is created in the right portion of the view; in the example given, the conversion is complete and correct.  The set of NFA states in shown in the label below each DFA state.  Between the two diagrams for the two automatons is a bar that may be dragged left and right to adjust the allocation of sizes between the two diagrams.</P>

<H2>Expansion of States</H2>

<P>The first thing that happens is that the initial state is created.  The initial state's set for the DFA consists of the initial set of the NFA, and the closure of all states reachable from that initial state on lambda transitions.  This is done for the user: the only thing the user sees at first in the DFA constructor is this one initial state.  In the example above, the initial NFA state is <VAR>q0</VAR> and there are no lambda transitions from it, so the initial set is only <VAR>0</VAR>.</P>

<P>One then uses the "Expand Group on Terminal" tool (<IMG SRC="../ICON/expand_group.gif" ALT="Expand Group on Terminal" WIDTH="16" HEIGHT="16">) to build the DFA.  When this tool is active, one drags from a state (or group) into empty space.</P>

<CENTER><IMG SRC="images/2dfa-terminal.png" ALT="Terminal query window." WIDTH="307" HEIGHT="125" BORDER="1"></CENTER>

<P>The user is then queried as to what symbol to expand this group on, shown above.  For example, for the initial set of <VAR>q0</VAR>, one can expand on <VAR>1</VAR> since there are transitions from that state in the original NFA.</P>

<CENTER><IMG SRC="images/2dfa-group.png" ALT="Set of states query window." WIDTH="367" HEIGHT="125" BORDER="1"></CENTER>

<P>Assuming that the original set of states actually expands on the input terminal, the user is then queried above the set of NFA states that group expands to on that terminal.  In our running example, from the diagram we see that <VAR>q0</VAR> expands on <VAR>1</VAR> to the states <VAR>q0</VAR>, <VAR>q1</VAR> and <VAR>q2</VAR>.  While <VAR>q0</VAR> and <VAR>q1</VAR> are fairly obvious, less obvious is the presence of <VAR>q2</VAR>.  However, since there is a lambda transition from <VAR>q1</VAR> to <VAR>q2</VAR>, the closure of <VAR>q1</VAR> implies <VAR>q2</VAR>.</P>

<P>One would therefore enter <VAR>0 1 2</VAR> into the dialog shown above, as shown.  (JFLAP would also accept <VAR>q0 q1 q2</VAR>, or <VAR>0,1,2</VAR>, or <VAR>q0, q1, q2</VAR>, etc etc.)</P>

<P>When the user enters the set of states, and it is correct, the new DFA state is created at the point in empty space where the user originally dragged to.  (If the user is incorrect, the user is gently chastised and nothing is added.)</P>

<P>Final states in the DFA are those states whose NFA state sets contain at least one final state from the NFA: in the example, notice that every state in the DFA with the NFA final state <VAR>q3</VAR> in its set is a final state.  JFLAP will detect if the user entered any states that were final states, and if so make the state it creates a final state.</P>

<P>The "Done?" button will check the DFA to see if it is complete.  If it is, then this completed DFA will be exported to its own window, where it may be treated like any other FA.</P>

<H2>Help</H2>

<P>While it is possible for one to build the DFA entirely through use of the "Expand Group on Terminal" tool (<IMG SRC="../ICON/expand_group.gif" ALT="Expand Group on Terminal" WIDTH="16" HEIGHT="16">), one also has the option of letting JFLAP do some or all of the work.</P>

<P>The "State Expander" tool (<IMG SRC="../ICON/state_expander.gif" ALT="Expand State" WIDTH="16" HEIGHT="16">) is a moderate help tool.  When active, if you click on a state, it will expand that group on all terminals to all other groups it goes to.  Any newly created states will be randomly placed.</P>

<P>The "Complete" button will complete the DFA entirely.</P>

<H2>Details and Detritus</H2>

<P>The NFA to DFA procedure depends on having transitions with at most one character.  As JFLAP allows multiple character transitions, all of these are automatically broken up: the transition <VAR>abc</VAR> would be broken into three transitions, with two new bridge states created.</P>

<P>Additionally, when expanding a set of states, if the destination set of states is already in the DFA, instead of dragging to empty space, one may drag to that second set of states, and the user will not be queried as to the set of states it goes to.  It is considered that the user has already made that choice.  However, if the user <EM>does</EM> drag to empty space and input a set that already exists, then a new state will not be created; it clearly does not do to have multiple identical sets.</P>

</BODY></HTML>
